#if 0
#include "Avalon/Network/MulticastSocketChannel.hpp"
#include "Avalon/Base/NotImplementedException.hpp"
#include "Avalon/IO/ClientConnection.hpp"
#include "Avalon/IO/Reader.hpp"
#include "Avalon/IO/Writer.hpp"

using namespace Avalon;
using namespace Avalon::IO;
using namespace Avalon::Network;
using namespace Avalon::Threading;
using namespace boost;
using namespace std;

namespace {
  class MulticastConnection : public ClientConnection {
    public:
      MulticastConnection(MulticastSocket* socket,
          const IpAddress& groupAddress)
          : m_isConnected(false),
            m_socket(socket),
            m_groupAddress(groupAddress) {}

      virtual ~MulticastConnection() {
        Close();
      }

      virtual bool IsConnected() {
        boost::lock_guard<boost::mutex> lock(m_mutex);
        return m_isConnected;
      }

      virtual void Close() {
        {
          boost::lock_guard<boost::mutex> lock(m_mutex);
          if(!m_isConnected) {
            return;
          }
          m_socket->Close();
          m_isConnected = false;
        }
        m_closedSignal();
      }

      virtual connection ConnectClosedSignal(
          const ClosedSignal::slot_type& slot) {
        boost::lock_guard<boost::mutex> lock(m_mutex);
        return m_closedSignal.connect(slot);
      }

      virtual connection ConnectClosedSignal(
          const ClosedSignal::slot_type& slot, bool* isConnected) {
        boost::lock_guard<boost::mutex> lock(m_mutex);
        *isConnected = m_isConnected;
        return m_closedSignal.connect(slot);
      }

      virtual void Connect() {
        boost::lock_guard<boost::mutex> lock(m_mutex);
        if(m_isConnected) {
          return;
        }
        m_socket->Open();
        m_isConnected = true;
      }

    private:
      boost::mutex m_mutex;
      bool m_isConnected;
      MulticastSocket* m_socket;
      IpAddress m_groupAddress;
      ClosedSignal m_closedSignal;
  };

  class MulticastReader : public Reader {
    public:
      MulticastReader(MulticastSocket* socket)
          : m_socket(socket) {}

      virtual ~MulticastReader() {}

      virtual void Read(void* destination, int size,
          Out<Async<int> > sizeRead) {
        BOOST_THROW_EXCEPTION(NotImplementedException(
          "MulticastReader::Read()"));
      }

      virtual void Read(Buffer* destination, Out<Async<int> > sizeRead) {
        Async<DatagramPacket>::State readResult;
        m_packet.ConnectFinishedSignal(m_readSlot, Store(readResult));
        m_socket->Receive(destination, Store(m_packet));
      }

    private:
      MulticastSocket* m_socket;
      Async<DatagramPacket> m_packet;

      void OnReceive() {
        if(inResult->GetState() == BaseAsync::EXCEPTION) {
          outResult->CopyException(inResult);
          return;
        }
        outResult->SetResult(inResult->Get().GetSize());
      }
  };

  class MulticastWriter : public Writer {
    public:
      MulticastWriter(MulticastSocket* socket)
          : m_socket(socket) {}

      virtual void Write(const void* data, int size, Out<Async<void> > result) {
        BOOST_THROW_EXCEPTION(NotImplementedException(
          "MulticastWriter::Write()"));
      }

      virtual void Write(const Buffer& data, Out<Async<void> > result) {
        BOOST_THROW_EXCEPTION(NotImplementedException(
          "MulticastWriter::Write()"));
      }

    private:
      MulticastSocket* m_socket;
  };
}

MulticastSocketChannel::MulticastSocketChannel(MulticastSocket* socket,
    const IpAddress& address)
    : m_connection(new MulticastConnection(socket, address)),
      m_reader(new MulticastReader(socket)),
      m_writer(new MulticastWriter(socket)) {}

MulticastSocketChannel::~MulticastSocketChannel() {}

Connection& MulticastSocketChannel::GetConnection() {
  return *m_connection;
}

Reader& MulticastSocketChannel::GetReader() {
  return *m_reader;
}

Writer& MulticastSocketChannel::GetWriter() {
  return *m_writer;
}
#endif
